package cn.zwk.template;

import cn.zwk.request.HttpMethod;

import java.util.Collections;
import java.util.Map;

/**
 * 每个语句列对应一个请求模板：URL/Headers/Body 都是可渲染字符串，支持占位符。
 * 约定占位符：{key}、{query}；实现可扩展。
 */
public final class RequestTemplate {
    private final String id; // 可使用列名或自定义ID
    private final HttpMethod method;
    private final String urlTemplate;
    private final Map<String, String> headerTemplates;
    private final String bodyTemplate; // 可为空

    public RequestTemplate(String id, HttpMethod method, String urlTemplate,
                           Map<String, String> headerTemplates, String bodyTemplate) {
        this.id = id;
        this.method = method;
        this.urlTemplate = urlTemplate;
        this.headerTemplates = headerTemplates == null ? Map.of() : Map.copyOf(headerTemplates);
        this.bodyTemplate = bodyTemplate;
    }

    public String id() { return id; }
    public HttpMethod method() { return method; }
    public String urlTemplate() { return urlTemplate; }
    public Map<String, String> headerTemplates() { return Collections.unmodifiableMap(headerTemplates); }
    public String bodyTemplate() { return bodyTemplate; }
}

